//
//  BookShelfCollectionViewCell.m
//  GenericProject
//
//  Created by 大鹏 on 2022/7/29.
//  Copyright © 2022 漠然丶情到深处. All rights reserved.
//

#import "BookShelfCollectionViewCell.h"

@interface BookShelfCollectionViewCell ()

@property(nonatomic,strong)UIImageView *coverImageView;
@property(nonatomic,strong)UILabel *nameLabel;

@end

@implementation BookShelfCollectionViewCell

- (id)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        [self createSubviews];
    }
    return self;
}

- (void)createSubviews {
    UIView *bgView = [[UIView alloc]init];
    bgView.backgroundColor = [UIColor lsLigthColor:LSWhiteColor darkColor:[UIColor lightGrayColor]];
    bgView.layer.masksToBounds = YES;
    bgView.layer.cornerRadius = LSSYRealValue(4);
    [self.contentView addSubview:bgView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).with.offset(0);
        make.left.equalTo(self.contentView).with.offset(0);
        make.right.equalTo(self.contentView.mas_right).with.offset(0);
        make.bottom.equalTo(self.contentView.mas_bottom).with.offset(0);
    }];
    
    self.coverImageView = [[UIImageView alloc]init];
    self.coverImageView.backgroundColor = [UIColor lightGrayColor];
    [bgView addSubview:self.coverImageView];
    [self.coverImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bgView).with.offset(0);
        make.left.equalTo(bgView).with.offset(0);
        make.right.equalTo(bgView.mas_right).with.offset(0);
        make.bottom.equalTo(bgView.mas_bottom).with.offset(LSSYRealValue(-40));
    }];
    
    self.nameLabel = [[UILabel alloc]init];
    self.nameLabel.font = LSSystemFont(LSSYRealValue(12));
    self.nameLabel.textColor = [UIColor lsLigthColor:LSBlackColor darkColor:LSWhiteColor];
    self.nameLabel.numberOfLines = 0;
    [bgView addSubview:self.nameLabel];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.coverImageView.mas_bottom).with.offset(0);
        make.left.equalTo(bgView).with.offset(LSSYRealValue(10));
        make.right.equalTo(bgView.mas_right).with.offset(LSSYRealValue(-10));
        make.bottom.equalTo(bgView.mas_bottom).with.offset(0);
    }];
}

- (void)setBookNameString:(NSString *)bookNameString {
    _bookNameString = bookNameString;
    
    self.nameLabel.text = [bookNameString stringByReplacingOccurrencesOfString:@".txt" withString:@""];
}

@end
